package router

import (
	"crow-docker/src/service"
	"fmt"
	"github.com/dgrijalva/jwt-go"
	"github.com/gin-gonic/gin"
)

func LiuBei(c *gin.Context) {

	strToken := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2ODEzNTEyNjMsImlhdCI6MTY4MTI2NDg2MywidXNlcl9pZCI6MSwicGFzc3dvcmQiOiJCb2U4ODg4ODgjIiwidXNlcm5hbWUiOiJsaXVCZWkiLCJmdWxsX25hbWUiOiJsaXVCZWkiLCJwZXJtaXNzaW9ucyI6W119.p_lmaVuq_c5vH67plixwxTPp6W1tmC8fa0rftW7MXt0"
	token, err := jwt.ParseWithClaims(strToken, &service.JWTClaims{}, func(token *jwt.Token) (interface{}, error) {
		return []byte(service.Secret), nil
	})
	if err != nil {
		return
	}
	claims, _ := token.Claims.(*service.JWTClaims)
	if err != nil {
		return
	}

	fmt.Printf("%+v", claims)
	SetOK(c, token)
}

func Crow1() gin.HandlerFunc {
	return func(c *gin.Context) {

		c.Set("crow_01", "crow_1")
		fmt.Println("crow_01")
		c.Abort()
	}
}
